<?php

ini_set('date.timezone', 'PRC');

session_start();

// http://www.xxxx.test/index.php

$c = isset($_GET['c']) ? $_GET['c'] : 'home';
$a = isset($_GET['a']) ? $_GET['a'] : 'index';

// \Controllers\HomeController::

$controller ='\\Controllers\\' . ucfirst(strtolower($c)) . 'Controller';

spl_autoload_register('autoload');

function autoload($className) {
    // Controllers\HomeController
    $filePath = './' . str_replace('\\', '/', $className) . '.php';
    if (!file_exists($filePath)) {
        echo 'The Controller ' . $className . ' is not exists!'; exit;
    }
    include_once $filePath;
}


$app = new $controller();

if (!method_exists($app, $a)) {
    echo 'The method ' . $a . ' is not exists!'; exit;
}

echo $app->$a();